<template>
	<view>
		<u-navbar :borderBottom="false" back-text=" " :title="title"></u-navbar>
		<view v-if="list.length>0" class="connect">
			<!-- v-for="(item,index) in list" :key="index" -->
			<view  v-if="kor_type=='kor'"  >
				<view class="connect_title">
					{{list[0].name}}
				</view>
				<view class="address_info">
					<view class="address_info_item">
						<span>用户编号</span>
						<view class="address_info_item_right">
							<span>{{list[0].user_code}}</span>
							<image @click="copy(list[0].user_code)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item">
						<span>编号</span>
						<view class="address_info_item_right">
							<span>{{list[0].username}}</span>
							<image @click="copy(list[0].username)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item">
						<span>邮编</span>
						<view class="address_info_item_right">
							<span>{{list[0].ems}}</span>
							<image @click="copy(list[0].ems)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item">
						<span>手机号</span>
						<view class="address_info_item_right">
							<span>{{list[0].mobile}}</span>
							<image @click="copy(list[0].mobile)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item" style="border: none;">
						<span>地址</span>
						<view class="address_info_item_right" >
							<image @click="copy(list[0].city+list[0].address)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address" style="padding-bottom: 32rpx	;">
							{{list[0].city+list[0].address}}
					</view>
				</view>
			</view>
			<view v-if="kor_type=='kor'" >
				<view class="connect_title">
					{{list[1].name}}
				</view>
				<view class="address_info">
					<!-- <view class="address_info_item">
						<span>邮编</span>
						<view class="address_info_item_right">
							<span>{{list[1].ems}}</span>
							<image @click="copy(list[1].ems)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view> -->
					<view class="address_info_item">
						<span>手机号</span>
						<view class="address_info_item_right">
							<span>{{list[1].mobile}}</span>
							<image @click="copy(list[1].mobile)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item" style="border: none;">
						<span>地址</span>
						<view class="address_info_item_right" >
							<image @click="copy(`${list[1].city+list[1].address}-${list[1].user_code}`)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address">
							{{list[1].city+list[1].address}}-{{list[1].user_code}}
					</view>
				</view>
			</view>
			<view  v-if="kor_type=='chn'"  >
				<view class="connect_title">
					{{list[0].name}}
				</view>
				<view class="address_info">
					<view class="address_info_item">
						<span>收货人</span>
						<view class="address_info_item_right">
							<span>杨琳({{list[0].user_kor_code}})</span>
							<image @click="copy(`杨琳(list[0].user_kor_code)`)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					
					<view class="address_info_item">
						<span>邮编</span>
						<view class="address_info_item_right">
							<span>{{list[0].ems}}</span>
							<image @click="copy(list[0].ems)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item">
						<span>手机号</span>
						<view class="address_info_item_right">
							<span>{{list[0].mobile}}</span>
							<image @click="copy(list[0].mobile)" style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address_info_item" style="border: none;">
						<span>地址</span>
						<view  @click="copy_all(list[0])" class="address_info_item_right" style="font-size: 22rpx; color: #bfbfbf;" >
							一键复制
							<image  style="width: 24rpx; height: 24rpx;margin-left: 16rpx;" src="../../static/icon/coppy.png" mode=""></image>
						</view>
					</view>
					<view class="address" style="padding-bottom: 32rpx	;">
							{{list[0].city+list[0].address}}{{list[0].code}}({{list[0].user_kor_code}})
					</view>
				</view>
			</view>
			<image v-if="kor_type=='chn'" src="https://www.mengkahuyu.com/index_png/fahuo_ZN.png" mode="widthFix" style="width:100%;"></image>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title:'仓库地址',
				kor_type:'',
				list:[]
			}
		},
		onLoad() {
			
		},
		onShow() {
			this.kor_type = uni.getStorageSync('kor_type')?uni.getStorageSync('kor_type'):''
			// console.log(this.kor_type)
			this.getList()
			
		},
		methods: {
			copy_all(item){
				var text = `${item.city}${item.address}${item.code}-${item.user_kor_code} 邮编:${item.ems} 电话:${item.mobile} 收件人:杨琳-${item.user_kor_code} `
				this.copy(text)
			},
			getList(){
				var data = {
					
				}
				this.$wqzApi.index_warehouse(data).then(res=>{
					this.list = res.data
				})
			},
			copy(text){
				var that = this
				uni.setClipboardData({
					data: text,
					success: function(t) {
						if(that.kor_type=='kor'){
							uni.showToast({
							    title: '复制成功',
							    //将值设置为 success 或者直接不用写icon这个参数
							    icon: 'success',
							    //显示持续时间为 2秒
							    duration: 2000
							})
						}else{
							uni.showModal({
							    title: '复制成功',
							    content: '购物APP智能识别可能无法识别到编号 , 请仔细核实 !',
							});
						}
						
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url('./index.scss');
</style>
